<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : playerStatistics.xsl
    Created on : Utorok, 2011, máj 10, 0:06
    Author     : Football-Statistics Team
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" omit-xml-declaration="yes" media-type="html/text"/>

    <xsl:param name="player"/>
    <xsl:param name="team"/>
    <xsl:param name="all_teams"/>
    <xsl:param name="matches"/>
    <xsl:param name="minutes"/>
    <xsl:param name="goals"/>
    <xsl:param name="red_cards"/>
    <xsl:param name="yellow_cards"/>
    <xsl:param name="chosen_team"/>    

    <xsl:template match="/playerStatistics">
        <xsl:choose>
            <xsl:when test="$chosen_team != ''">
                <h2><xsl:value-of select="$chosen_team"/></h2>
            </xsl:when>
            <xsl:otherwise>
                <h2><xsl:value-of select="$all_teams"/></h2>
            </xsl:otherwise>
        </xsl:choose>        
        <table id="sortTable" class="tablesorter">
            <thead>
                <tr>
                    <th> 
                      <xsl:value-of select="$player"/>
                    </th>
                    <th>
                        <xsl:value-of select="$team"/>
                    </th>                    
                    <th>
                        <xsl:value-of select="$goals"/>
                    </th>
                    <th>
                        <xsl:value-of select="$matches"/>
                    </th>
                    <th>
                        <xsl:value-of select="$minutes"/>
                    </th>
                    <th>
                        <xsl:value-of select="$yellow_cards"/>
                    </th>
                    <th>
                        <xsl:value-of select="$red_cards"/>
                    </th>
                </tr>
            </thead>
            <tbody>
                <xsl:choose>
                    <xsl:when test="$chosen_team != ''">
                        <xsl:apply-templates select="player[team=$chosen_team]">
                            <xsl:sort select="@name" order="ascending"/>
                        </xsl:apply-templates>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates select="player">
                            <xsl:sort select="@name" order="ascending"/>
                        </xsl:apply-templates>
                    </xsl:otherwise>
                </xsl:choose>
            </tbody>
        </table>
    </xsl:template>

    <xsl:template match="player">
                <tr>
                    <td><xsl:value-of select="@name"/></td>
                    <td><xsl:value-of select="team"/></td>
                    <td><xsl:value-of select="goals"/></td>
                    <td><xsl:value-of select="games"/></td>
                    <td><xsl:value-of select="minutes"/></td>
                    <td><xsl:value-of select="cards/yellow"/></td>
                    <td><xsl:value-of select="cards/red"/></td>
                </tr>
    </xsl:template>

</xsl:stylesheet>
